package lion.workflow.handler;

import java.lang.annotation.Annotation;

import lion.dev.lang.MapJ;
import lion.framework.core.anno.AnnoProcessor;
import lion.framework.core.anno.AnnotationProcessorManager;
import lion.framework.core.anno.IAnnotationProcessor;
import lion.workflow.IWorkflowHandler;

/**
 * 
 * WorkflowHandler 注解扫描处理器
 * 
 * @author lion
 * @email hl_0074@sina.com
 * @date 2014年8月27日
 */
@AnnoProcessor(WorkflowHandler.class)
public class WorkflowHandlerAnnoProcessor implements IAnnotationProcessor {

	@SuppressWarnings("unchecked")
	@Override
	public void processe(MapJ context, Annotation anno) throws Exception {

		WorkflowHandler sh = (WorkflowHandler) anno;

		String name = sh.value();
		Class<?> clazz = context.getE(AnnotationProcessorManager.ANNO_CONTEXT_CLASS);
		if (IWorkflowHandler.class.isAssignableFrom(clazz)) {
			WorkflowHandlers.regist(name, (Class<IWorkflowHandler>) clazz);
		}
	}
}
